package top.breezes.service;

import org.springframework.stereotype.Service;
import top.breezes.model.User;
import top.breezes.repository.UserRepository;

import javax.annotation.Resource;
import java.util.Optional;

/**
 * @author yuchengxin
 * @Date 2020-05-28 11:02
 * @Description
 */
@Service
public class UserService {

    @Resource
    private UserRepository userRepository;

    /**
     * 根据id查询
     *
     * @param uid 用户id
     * @return
     */
    public User findById(Long uid) {
        return userRepository.findById(uid).orElseThrow(
                () -> new RuntimeException("用户不存在")
        );
    }

}
